﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ATEGo
{
    //———————————————————————【外部需要赋值的普通变量】————————————————————————
    public partial class Executor
    {
        //———————————————————————外部赋值————————————————————————
        /// <summary>
        /// 开始时界面的操作
        /// </summary>
        public Action Action_Start { get; set; }
        /// <summary>
        /// 测试完成时界面的操作
        /// </summary>
        public Action Action_End { get; set; }
        /// <summary>
        /// 用户主动停止界面的操作，不会再执行Action_End
        /// </summary>
        public Action Action_Stop { get; set; }
        /// <summary>
        /// 外界写cmd的Log的方法
        /// </summary>
        public Action<string> Action_WriteCmdLog { get; set; }
        /// <summary>
        /// 外界写flow的Log的方法
        /// </summary>
        public Action<string> Action_WriteFlowLog { get; set; }
        /// <summary>
        /// 执行下一条命令时发生
        /// </summary>
        public Action<int> Action_ExeNextCmd { get; set; }
        /// <summary>
        /// 是否打印调试信息
        /// </summary>
        public bool IsPrintDebugInfo { get; set; } = true;

        //———————————————————————一般变量————————————————————————
        /// <summary>
        /// 线程几启动的执行器
        /// </summary>
        private int ThreadIndex { get; set; }
        /// <summary>
        /// 外部的主界面，需要将界面的动作提交到主界面去执行
        /// </summary>
        private IExecutorForm This_Form { get; set; }

        //———————————————————————测试树————————————————————————
        /*
         * 测试树TestTree：TestTree.json，包含 branch、testOrder(TestOrderItem)、cmdSuitsFile
         * 测试流程项：(TestOrderItem)->items、cmdSuitsFile、sequence
         * ------------------------------------------------
         * 测试流程：(CmdSuits)->cmdSuits(CmdTag)
         * 测试命令集tag：(CmdTag)->cmdTag、subCmds(CmdDict)、result
         * 具体命令：(CmdDict)
         */


        

      
        //———————————————————————回显————————————————————————
        /// <summary>
        /// 目前执行的回显的暂存区
        /// </summary>
        private StringBuilder Running_Cmd_Buffer { get; set; } = new StringBuilder();
        /// <summary>
        /// 上一次命令的回显
        /// </summary>
        private string Last_Cmd_Buffer { get; set; } = "";
        /// <summary>
        /// 指示是否接收回显
        /// </summary>
        private bool IsReceiveEcho { get; set; } = false;

        //———————————————————————命令的变量替换————————————————————————
        /// <summary>
        /// 命令里面定义的变量
        /// </summary>
        public Dictionary<string, string> Params_InCmd { get; set; } = new Dictionary<string, string>();
        /// <summary>
        /// 抓取正则的默认变量，$0表示整个，$1组一，$2组二，....
        /// </summary>
        private Dictionary<string, string> Params_GrabResult { get; set; } = new Dictionary<string, string>();

        

        //———————————————————————进度条————————————————————————
        /// <summary>
        /// 展示的进度条
        /// </summary>
        public ProgressBar This_ProgressBar { get; set; }

        /// <summary>
        /// 目前ProgressBar的值
        /// </summary>
        public Action<string> Prg_ShowValue { get; set; }

        /// <summary>
        /// 设置的进度个数，每完成一个加1
        /// </summary>
        private int Pb_Count { get; set; }

    }
}
